<template>
  <div class="zan-page">
    <WaterfallFlowImgList id="1" :list="list" :columns="columns" :defaultw="414" v-if="list.length>0"/>
    <Empty text="没有找到符合条件的结果~" v-if="list.length==0&&!isloading"/>
    <div class="pro-bot-loading" v-if="isloading">
        <i class="el-icon-loading"></i>
    </div>
    <div class="no-more-text" v-if="!hasMore&&!isloading&&list.length>0">没有更多了</div>
  </div>
</template>
<script>
import Empty from '@/components/Empty'
import WaterfallFlowImgList from '@/components/WaterfallFlowImgList'
import api from '@/api/api'
export default {
  data() {
    return {
      isloading:true,
      collectIds:[],
      columns:6,
      hasMore:true,
      list: [],
      params: {
        pageNum: 1,
        pageSize: 50,
        isAsc: 'desc',
        orderByColumn: 'createTime',
        keyword: '',
        type: 4
      }
    }
  },
  props: ['uid','isself'],
  components: {
    WaterfallFlowImgList,Empty
  },
  mounted() {
    this.params.praise=localStorage.getItem('userId');
  },
  methods: {
    handleSearch(){
      this.hasMore=true;
      this.list=[];
      this.params.pageNum=1;
      this.queryList();
    },
    loadNext(){
      this.params.pageNum++;
      this.queryList();
    },
        calculateTilt(corners){
            const{x:x1,y:y1}=corners[0];//左上
            const{x:x2,y:y2}=corners[1];// 右上
            // 计算 dy 和 dx
            const dy=y2-y1;
            const dx=x2-x1;
            //计算倾角(弧度->角度)
            const angle =Math.atan2(dy,dx)*(180 /Math.PI);
            // 返回角度
            return angle;
        },
    async queryList() {
      this.isloading=true;
      let params=Object.assign({},this.params);
      if(!this.isself){
        params.praise=this.$route.params.id;
      }
      if(params.pageNum==1){
        // this.list=this.$bhelper.vlist;
      }
      let res = await api.searchImgs(params);
      this.isloading=false;
      let that = this;
      let old = that.list;
      let datas = res.data.images.list;
      datas.forEach(item => {
        item.show=false;item.showOther=false;
        that.$bhelper.convertImgItem(item,that);
      })
      let totalPage = res.total % that.params.pageSize == 0 ? res.total / that.params.pageSize : parseInt(res.total / that.params.pageSize) + 1;
      if(datas.length>0)
        this.params.last=datas[datas.length-1].id;
      if (datas.length<that.params.pageSize) {
        that.hasMore = false
      } else {
        that.hasMore = true
      }
      
      if(params.pageNum==1){
        this.list=datas;
      }else{
        that.list = [...old, ...datas];
      }
      that.$emit('loaded')
    },
    handleGmCatePrev() {
      this.gmswiper.slidePrev()
    },
    handleGmCateNext() {
      this.gmswiper.slideNext()
    }
  }
}
</script>

<style lang="less">
.zan-page {
  display: inline-block;
  width: 100%;
  padding-bottom:150px;

  .gm-cate-page-prev {
    background: url('../../../assets/pro/more_right_arrow.svg') no-repeat;
    background-size: cover;
    width: 50px;
    height: 50px;
    transform: rotate(180deg);
    z-index: 1;
    left: -30px !important;
    top: 33px;
    border-radius: 8px;

    &:after {
      display: none;
    }

    &:hover {
      background: url('../../../assets/pro/more_right_arrow.svg') no-repeat;
      // opacity:.6 !important;
      background-size: cover;
    }
  }

  .gm-cate-page-next {
    background: url('../../../assets/pro/more_right_arrow.svg') no-repeat;
    background-size: cover;
    width: 50px;
    height: 50px;
    z-index: 1;
    border-radius: 8px;
    right: 15px;

    &:after {
      display: none;
    }

    &:hover {
      background: url('../../../assets/pro/more_right_arrow.svg') no-repeat;
      background-size: cover;
      // opacity:.6 !important;
    }
  }

  .page-tit {
    line-height: 37px;
    font-size: 26px;
    color: #fff;
    margin-bottom: 26px;
    font-weight: 500;
  }

  .m-at-con-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;

    .cover-all {
      width: 64px;
      height: 64px;
      position: relative;
      margin-left: 5px;
      text-align: center;

      margin-top: -16px;

      .img-wrap {
        display: flex;
        flex-wrap: wrap;
        width: 64px;
        height: 64px;
        border-radius: 50%;
        overflow: hidden;
        position: relative;

        .f-img {
          width: 32px;
          height: 32px;

          img {
            width: 100%;
            height: 100%;
            object-fit: cover;
          }
        }

        .text {
          font-weight: 500;
          color: #fff;
          font-size: 16px;
          position: absolute;
          height: 100%;
          width: 100%;
          display: flex;
          justify-content: center;
          align-items: center;
        }
      }

      &:after {
        position: absolute;
        pointer-events: none;
        content: ' ';
        border-radius: 50%;
        // border: 2px solid transparent;
        transition: all 0.15s ease-in-out;
        top: -4px;
        left: -4px;
        right: -4px;
        bottom: -4px;
        border: 2px solid #ff5967;
      }

      &:before {
        z-index: 1;
        position: absolute;
        left: 0;
        pointer-events: none;
        content: ' ';
        width: 100%;
        height: 100%;
        border-radius: 50%;
        background-color: rgba(0, 0, 0, 0.05);
        transition: background-color 0.2s ease-in-out;
        content: '\5168\90e8';
        color: #fff;
        font-size: 16px;
        line-height: 64px;
        font-weight: 500;
        text-align: center;
        background-color: rgba(0, 0, 0, 0.4);
      }

      &:hover {
        &:before {
          background: linear-gradient(173.76deg, rgba(255, 89, 103, .4) 3.85%, rgba(255, 89, 155, .4) 37.77%, rgba(255, 89, 104, .4) 95.07%);
        }
      }

      .title {
        line-height: 20px;
        margin-top: 6px;
        display: block;
        font-size: 14px;
      }
    }

    .mgr-at-btn {
      width: 66px;
      background: #29272f;
      font-size: 14px;
      text-align: center;
      color: #fff;
      border-radius: 8px;
      margin-left: 12px;
      line-height: 40px;
    }

    .c-aten-datas {
      margin-left: 46px;
      // padding-left:64px;
      max-width: 87%;
      position: relative;

      // padding-left:20px;
      // padding:20px;
      .atswiper {
        height: 90px;
        padding-top: 20px;
      }

      .li-cover-all {
        margin-right: 46px;
        width: 64px !important;
        text-align: center;

        // height:64px;
        &:before {
          display: none;
        }

        .img-wrap {
          overflow: inherit;

          // width:64px;
          // height:64px;
          .avatar {
            width: 100%;
            height: 100%;
            border-radius: 64px;
          }

          .take-def {
            width: 24px;
            height: 24px;
            background: url('../../../assets/pro/at_def_ico.svg') no-repeat;
            background-size: cover;
            position: absolute;
            right: 0px;
            bottom: 0px;
            z-index: 1;

            &:hover {
              background: url('../../../assets/pro/at_def_hover_ico.svg') no-repeat;
              background-size: cover;
            }
          }

          .not-myfans-plus {
            width: 24px;
            height: 24px;
            background: url('../../../assets/pro/plus_friend_ico.svg') no-repeat;
            background-size: cover;
            position: absolute;
            right: 0px;
            bottom: 0px;
            z-index: 1;
          }

          &:after {
            position: absolute;
            pointer-events: none;
            content: ' ';
            border-radius: 50%;
            // border: 2px solid transparent;
            transition: all 0.15s ease-in-out;
            top: -4px;
            left: -4px;
            right: -4px;
            bottom: -4px;
            border: 2px solid #ff5967;
          }
        }

        &:hover {
          cursor: pointer;

          &:before {
            background: linear-gradient(173.76deg, rgba(255, 89, 103, .4) 3.85%, rgba(255, 89, 155, .4) 37.77%, rgba(255, 89, 104, .4) 95.07%);
            z-index: 1;
            position: absolute;
            left: 0;
            pointer-events: none;
            content: " ";
            width: 100%;
            height: 100%;
            border-radius: 50%;
            background-color: rgba(0, 0, 0, .05);
            transition: background-color .2s ease-in-out;
            display: inline-block;
          }

          .take-def {
            background: url('../../../assets/pro/at_def_take_to.svg') no-repeat;
          }
        }

        .name {
          line-height: 20px;
          margin-top: 4px;
          display: block;
          font-size: 14px;
        }
      }

      .nobod {
        .img-wrap {
          &:after {
            display: none;
          }
        }

        &:after {
          display: none;
        }

        &:hover {
          &:after {
            position: absolute;
            pointer-events: none;
            content: ' ';
            border-radius: 50%;
            // border: 2px solid transparent;
            transition: all 0.15s ease-in-out;
            top: -4px;
            left: -4px;
            right: -4px;
            bottom: -4px;
            border: 2px solid #ff5967;
            display: inline-block;
          }
        }
      }
    }
  }

  .sub-page-tit {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 25px;

    .txt {
      font-size: 20px;
      color: #fff;
      font-weight: 500;
      line-height: 28px;
      margin-top: 25px;
      margin-bottom: 23px;
    }

    .filter-bx {
      display: flex;
      align-items: center;

      .seach-bx {
        width: 215px;

        input {
          background: #29272f;
          height: 40px;
          line-height: 40px;
          border-radius: 8px;
          border: none;
          padding-left: 36px;
          color: #fff;
          font-size: 14px;
          background-image: url('../../../assets/pro/header/search_icon.svg');
          background-repeat: no-repeat;
          background-position: 14px center;
          background-size: 16px 16px;
        }
      }
    }
  }

  .mk-rd-datas {
    .h-cover-ditem {
      width: 312px;

      .cover-box {
        display: flex;

        .mlft {
          width: 204px;
          min-width: 204px;
          height: 210px;
          border-radius: 16px;
          margin-right: 6px;
          overflow: hidden;

          img {
            width: 100%;
            height: 100%;
            object-fit: cover;
          }
        }

        .mrt {
          .m-cover-bx {
            width: 102px;
            height: 102px;
            border-radius: 16px;
            overflow: hidden;

            img {
              width: 100%;
              height: 100%;
              object-fit: cover;
            }

            &:first-child {
              margin-bottom: 6px;
            }
          }
        }
      }

      .u-bx {
        display: flex;
        align-items: center;
        margin-top: 8px;

        .avatar {
          width: 20px;
          height: 20px;
          object-fit: cover;
          margin-right: 7px;
          border-radius: 20px;
        }

        .name {
          font-size: 14px;
          color: #969696;
        }
      }
    }

    .waf-ligan-item {
      position: absolute;
      top: 10px;
      left: 10px;
      right: 10px;
      bottom: 10px;
      font-size: 1.2em;
      border: 2px solid #000;
      border-radius: 16px;
      transition: 0.1s all linear;
      overflow: hidden;

      &:hover {
        cursor: pointer;
        border: 2px solid #11CCB1;

        .hid-btn {
          display: inherit;
        }
      }

      .m-img {
        border-radius: 16px;
        height: 100%;
        width: 100%;
        object-fit: cover;
      }

      .author {
        position: absolute;
        bottom: 10px;
        left: 10px;
        background: rgba(255, 255, 255, 0.9);
        border-radius: 12px;
        padding: 10px 13px;
        width: 164px;
        cursor: pointer;

        .ar-tit {
          font-size: 14px;
          font-weight: 500;
          color: #383737;
          line-height: 20px;
          margin-bottom: 5px;
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
          background: url('../../../assets/pro/take_tit_icon.svg') no-repeat;
          background-position: left center;
          padding-left: 22px;
        }

        .u-box {
          display: flex;
          padding-left: 20px;

          .name {
            font-size: 14px;
            color: #969696;
            font-weight: 500;
          }

          .avatar {
            width: 20px;
            height: 20px;
            border-radius: 20px;
            margin-right: 7px;
          }
        }
      }

      .like-icon-btn {}

      .fav-btn {
        background-color: #11CCB1;
        color: #fff;
        height: 44px;
        line-height: 44px;
        // width:82px;
        position: absolute;
        top: 10px;
        right: 10px;
        font-size: 14px;
        border-radius: 12px;
        cursor: pointer;
        background-image: url('../../../assets/pro/un_favicon.svg');
        background-repeat: no-repeat;
        background-position: 11px center;
        padding-left: 35px;
        padding-right: 12px;

        &:hover {
          background-color: #f34972;
        }
      }

      .select-btn {
        width: 20px;
        height: 20px;
        position: absolute;
        left: 10px;
        top: 10px;
        background: url('../../../assets/pro/mutiple_select_pic.svg') no-repeat;
        background-size: cover;

        &.actived {
          background: url('../../../assets/pro/mutiple_selected_pic.svg') no-repeat;
          background-size: cover;
        }
      }

      .faved-btn {
        background-color: #fff;
        color: #000;
        height: 44px;
        line-height: 44px;
        // width:82px;
        position: absolute;
        top: 10px;
        right: 10px;
        font-size: 14px;
        border-radius: 12px;
        cursor: pointer;
        background-image: url('../../../assets/pro/faved_icon.svg');
        background-repeat: no-repeat;
        background-position: 11px center;
        padding-left: 35px;
        padding-right: 12px;
        opacity: 0.9;

        &:hover {
          opacity: 1;
        }
      }

      .xs-img-btn {
        background-image: url('../../../assets/pro/xs_img_cion.svg');
        background-repeat: no-repeat;
        background-position: center center;
        width: 40px;
        height: 40px;
        position: absolute;
        right: 10px;
        bottom: 10px;
        background-color: #fff;
        border-radius: 12px;
        cursor: pointer;
        opacity: 0.9;

        &:hover {
          opacity: 1;
        }
      }

      .hid-btn {
        display: none;
      }
    }
  }
}
</style>